import 'package:flutter/material.dart';
import 'package:window_size/window_size.dart';
import 'dart:io';
import 'screens/home_screen.dart';
import 'package:provider/provider.dart';
import 'providers/song_provider.dart';
import 'package:sqflite/sqflite.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';

void main() {
  // 初始化 FFI 数据库工厂
  databaseFactory = databaseFactoryFfi;
  if (Platform.isMacOS) {
    setWindowTitle('音乐播放器');
    setWindowMinSize(const Size(1000, 600));
    setWindowMaxSize(Size.infinite);
  }

  runApp(
    ChangeNotifierProvider(
      create: (_) => SongProvider(),
      child: const MusicPlayerApp(),
    ),
  );
}

class MusicPlayerApp extends StatelessWidget {
  const MusicPlayerApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '音乐播放器',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: HomeScreen(),
    );
  }
}